package top.yokey.shopnc.model;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

import top.yokey.base.base.BaseHttpClient;
import top.yokey.base.base.BaseHttpListener;
import top.yokey.shopnc.base.BaseConstant;

@SuppressWarnings("ALL")
public class IndexModel {

    private final String ACT = "index";
    private static volatile IndexModel instance;

    public static IndexModel get() {
        if (instance == null) {
            synchronized (IndexModel.class) {
                if (instance == null) {
                    instance = new IndexModel();
                }
            }
        }
        return instance;
    }

    public void index(BaseHttpListener baseHttpListener) {

        RequestParams requestParams = new RequestParams("https://frame.yokey.top/authorize/index/update/");
        requestParams.addBodyParameter("server", BaseConstant.URL_API);
        x.http().post(requestParams, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {

            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {

            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });

        BaseHttpClient.get().ready(ACT, Thread.currentThread().getStackTrace()[2].getMethodName())
                .get(baseHttpListener);

    }

    public void getGG(BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "getgg")
                .add("ac_id", "1")
                .get(baseHttpListener);

    }

    public void searchKeyList(BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "search_key_list")
                .get(baseHttpListener);

    }

}
